<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'upload.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
		#preview{width:100px;height:100px;border:1px solid #000;overflow:hidden;}
		#imghead {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);}
	</style>
	<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
	<script type="text/javascript" src="js/upload.js"></script> 
	<script type="text/javascript" src="js/swfobject.js"></script> 
	<link rel="stylesheet" type="text/css" href="js/uploadify.css" >
	<script type="text/javascript" src="js/jquery.uploadify.js"></script>
	<script >
		$(function() {
		    $("#file_upload").uploadify({
		    	'auto':false,
		    	'fileSizeLimit' : '5MB',
		    	'fileObjName' : 'file_upload',
		    	'fileTypeDesc' : 'bhb',
		    	'debug' : true,
		    	'fileTypeExts' : '*.gif; *.jpg; *.png',
		    	'buttonText'    : '选择文件',
		        'swf'      : 'js/uploadify.swf',
		        'uploader' : '../user/uploadAction',
		         'folder'  : 'attached',
		        'displayData'    : 'speed',
		        'onUploadSuccess' : function(file, data, response) {
		        		$("#imghead").attr("src", data);
		        		$("#file_name").attr("value", data);
            		alert( response + ':' + data);
        		}
		    });
		});
	</script> 
  </head>
  
  <body>
    <div id="preview">
		<img id="imghead" width=100 height=100 border=0 src='attached/images/20130316163933_197.jpg'>
		<input type="hidden" id="file_name" value="" />
	</div>
    <br/>  
    <input type="file" name="file_upload" id="file_upload" /><a href="javascript:$('#file_upload').uploadify('upload','*')">上传</a>   
  </body>
</html>
